{layout name="layout/default" /}

<form class="layui-form" action="" method="post">
    <div class="layui-form-item">
        <label class="layui-form-label">所属组别：</label>
        <div class="layui-input-block">
            {:build_select('group[]', $groupdata, null, ['class'=>'form-control selectpicker', 'multiple'=>'', 'data-rule'=>'required'])}
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">用户名：</label>
        <div class="layui-input-block">
            <input type="text" name="row[username]" lay-verify="title" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码：</label>
        <div class="layui-input-block">
            <input type="password" name="row[password]" lay-verify="title" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">邮箱</label>
        <div class="layui-input-inline">
            <input type="text" name="row[email]" lay-verify="email" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">昵称：</label>
        <div class="layui-input-block">
            <input type="text" name="row[nickname]" lay-verify="title" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">状态：</label>
        <div class="layui-input-block">
            <input type="radio" name="row[status]" value="正常" title="正常" checked="">
            <input type="radio" name="row[status]" value="隐藏" title="隐藏">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

<script>
    layui.extend({
        formSelects: '__JS__/formSelects' // {/}的意思即代表采用自有路径，即不跟随 base 路径
    })
    layui.use(['jquery', 'form', 'formSelects'], function() {
        var formSelects = layui.formSelects,
            form = layui.form,
            $ = layui.jquery;

        // formSelects.debug(true); //开启debug模式

        formSelects.selects({
            name: 'select',
            el: 'select[name="group[]"]',
            show: '#select-result',
            model: 'select',
            filter: 'test',
            change: function(data, arr) {
                console.log(data); //layui中form.on的完整数据
                console.log(arr); //已选中的数据
            },
        });
    })
</script>
</body>

</html>